package com.czh.controller;

import com.czh.domain.ResponseResult;
import com.czh.domain.entity.Comment;
import com.czh.domain.vo.CommentPageVo;
import com.czh.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
/**
 * @author caozaihui
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
        @GetMapping("/commentList")
    public ResponseResult<CommentPageVo> getArticleCommentList(Integer articleId,Integer pageNum,Integer pageSize){
        return commentService.getArticleCommentList(articleId,pageNum,pageSize);
    }
    @PostMapping
    public ResponseResult<Object> addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
    @GetMapping("/linkCommentList")
    public ResponseResult<CommentPageVo> getLinkCommentList(Integer pageNum,Integer pageSize){
        return commentService.getLinkCommentList(pageNum,pageSize);
    }
    @PostMapping( "/addMessageComment")
    public ResponseResult<Object> addMessageComment(@RequestBody Map<String,String> comment){
        return commentService.addMessageComment(comment.get("comment"));
    }
    @GetMapping("/messageCommentList")
    public ResponseResult<CommentPageVo> getMessageCommentList(Integer pageNum,Integer pageSize){
            return commentService.getMessageCommentList(pageNum,pageSize);
    }
    @PostMapping("/replyMessageComment")
    public ResponseResult<Object> replyMessageComment(@RequestBody Comment comment){
        System.out.println(comment.toString());
            return commentService.replyMessageComment(comment);
    }
}
